<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
		<title>我的证书列表页</title>
		<link rel="stylesheet" type="text/css" href="../../css/api.css" />
		<link rel="stylesheet" href="../../css/mui.min.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/weui.min.css" />
		<link rel="stylesheet" href="../../css/base.css"/>
		<link rel="stylesheet" href="../../css/personal.css">
		<link rel="stylesheet" href="../../css/CFNetPP_Base.css">
		<style>
			.attestation  .mui-table-view-cell:active {
				background: #fff;
			}
			.mui-table-view:after {
				position: inherit;
			}
			.course-image {
				background-image: url(../../image/course_placehoder.png);
				background-size: 100% 180px;
			}
		</style>
	</head>
	<body>
		<div id="main" style="margin-top: 0;" class="attestation">
			<ul class="mui-table-view" id="list_id">
				<!--	<li   dataid="' + index + '" class="mui-table-view-cell mui-media list_item">
				<a href="javascript:;">
				<div class="mui-media-body">
				<span class="font16 nameSpace font_balck" id="workName"> 世界经济 </span>
				<span class="Attestation_btn2" onclick="openApplyScore(' + index + ')"> 申请证书</span>
				<span class="Attestation_btn mui-pull-right" onclick="openAnalysis(' + index + ')">评测分析 </span>
				</div> <img class="listImg " src="http://base.cfnet.org.cn/static/15107/15107_12.gif" onclick="ShowImage(' + index + ')"> </a>
				</li>
				<div class="interval"></div>
				<li   dataid="' + index + '" class="mui-table-view-cell mui-media list_item">
				<a href="javascript:;">
				<div class="mui-media-body">
				<span class="font16 nameSpace font_balck" id="workName"> 世界经济 </span>
				<span class="Attestation_btn2" onclick="openApplyScore(' + index + ')"> 申请证书</span>
				<span class="Attestation_btn mui-pull-right" onclick="openAnalysis(' + index + ')">评测分析 </span>
				</div> <img class="listImg " src="http://base.cfnet.org.cn/static/15107/15107_12.gif" onclick="ShowImage(' + index + ')"> </a>
				</li>
				<div class="interval"></div>-->
			</ul>
			<div class="noSign"  id="noData" hidden="hidden">
				<img src="../../image/icon_img.png" width="60%">
				<p class="font16 top_15 base_dark_grey" >
					暂无数据
				</p>
			</div>
			<div class="loadFailure" hidden="hidden" id="noNet">
				<img src="../../image/icon_img01.png" width="60%">
				<p class="" >
					数据加载失败
				</p>
				<p>
					请检查您的网络
				</p>
				<button type="button" class="mui-btn mui-btn-outlined" >
					重新加载
				</button>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script src="../../script/jquery.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script src="../../script/common.js"></script>
	<script type="text/javascript">
		var refreshCount = 0;
		//更新数据条数
		var dataArr = new Array();
		var weightratio = new Array();
		var page = 1;
		var row = 10;
		var applyType = '0';
		apiready = function() {
			ReceNotifi();
			showProgress();
			loadNewData();
			setRefreshHeader();
			setPullUpRefresh();
		}
		function ReceNotifi() {
			api.addEventListener({
				name : 'ApplySuccess'
			}, function(ret, err) {
				//coding...
				loadNewData();
			});
		}

		function loadNewData() {
			page = 1;
			loadData();
		}

		function loadMoreData() {
			page++;
			loadData();
		}

		function loadData() {
			var param = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjid'),
				page : page,
				rows : row,
			};
			cfnetppPOST(url_showCert, param, true, function(data, status) {
				//											alert(JSON.stringify(data));
				api.refreshHeaderLoadDone();
				hideProgress();
				if (status == 'success') {
					$('#noNet').hide();
					if (data.code == 200) {
						$('#noData').hide();
						var list = data.data.data;
						if (list != null && list.length > 0) {
							refreshCount = list.length;
							var listArr = new Array();
							var htmlString = new String();
							if (page == 1) {
								multiplePicturesCache({
									picArr : list, //包含图片数组
									picKey : 'img'//图片对应的字段
								}, function(imageArr) {
									list = imageArr;
									for (var i = 0; i < list.length; i++) {
										var weeklyData = list[i];
										var data = {
											id : weeklyData.quarter_id,
											qname : weeklyData.qname,
											analyze : weeklyData.analyze,
											img : weeklyData.img,
											imgurl : weeklyData.imgurl,
											qability : weeklyData.qability,
											iscertificate : weeklyData.iscertificate,
											certificate_money : weeklyData.certificate_money
										};
										listArr.push(data);
										htmlString += htmlStringWithName(data, i);
									}
									dataArr = listArr;
									$('#list_id').html(htmlString);
								});
							} else {
								multiplePicturesCache({
									picArr : list, //包含图片数组
									picKey : 'img'//图片对应的字段
								}, function(imageArr) {
									list = imageArr;
									var oldCount = dataArr.length;
									for (var i = 0; i < list.length; i++) {
										var index = oldCount + i;
										var weeklyData = list[i];
										var data = {
											id : weeklyData.quarter_id,
											qname : weeklyData.qname,
											analyze : weeklyData.analyze,
											img : weeklyData.img,
											imgurl : weeklyData.imgurl,
											qability : weeklyData.qability,
											iscertificate : weeklyData.iscertificate,
											certificate_money : weeklyData.certificate_money
										};
										listArr.push(data);
										htmlString += htmlStringWithName(data, index);
									}
									dataArr = dataArr.concat(listArr);
									$('#list_id').append(htmlString);
								});
							}
						} else {
							if (page == 1) {
								$('#noData').show();
							} else {
								api.toast({
									msg : '暂无数据',
									duration : 2000,
									location : 'bottom'
								});
							}
							$('#list_id').html('');
						}
					} else {
						if (page == 1) {
							$('#list_id').html('');
							$('#noData').show();
						}
					}
				} else {
					$('#noNet').show();
				}
			});
		}

		function htmlStringWithName(list, index) {
			var imageUrl = '';
			var applyStr = '';
			var iscertificate = list.iscertificate;
			if (list.img != '') {//包含
				imageUrl = list.img;
			} else {
				imageUrl = 'http://' + list.img;
			}
			// if (iscertificate == '2') {
			// 	applyStr = '<span class="Attestation_btn2" onclick="openApply(' + index + ')"> 申请证书</span>'
			// } else {
			// 	applyStr = '<span class="Attestation_btn2" onclick="openApplyScore(' + index + ')"> 申请证书</span>'
			// }
			return '<li   dataid="' + index + '" class="mui-table-view-cell mui-media list_item">' + '<a href="javascript:;">' + '<div class="mui-media-body">' + '<span class="font16 nameSpace font_balck" id="workName"> ' + list.qname + '</span>' +  '</div>' + '<img class="listImg course-img" src="' + imageUrl + '" onclick="ShowImage(' + index + ')"  onerror="Imgnofind()">' + ' </a>' + '</li>' + '<div class="interval"></div>';
		}

		//		//查看认证证书全图页
		function ShowImage(index) {
			var data = dataArr[parseInt(index)];
			var imgArr = new Array();
			var files = '';
			if (data.imgurl != '') {//包含
				files = data.imgurl;
			} else {
				files = 'http://' + data.imgurl;
			}
			imgArr.push(files);
			showimg(imgArr, 0);
		}

		//打开测评分析页
		function openAnalysis(index) {
			var data = dataArr[parseInt(index)];
			if (data.analyze != null && data.analyze != "") {
				api.openWin({useWKWebView:true,
					name : 'EvaluationAnalysisFrame',
					url : 'EvaluationAnalysisFrame.html',
					pageParam : {
						analyze : data.analyze,
						id : data.id //企业id
					}
				});
			} else {
				api.toast({
					msg : '暂无测评分析，请耐心等待'
				});
			}
		}

		function openApply(index) {
			var data = dataArr[parseInt(index)];
			api.openWin({useWKWebView:true,
				name : 'ApplyCertificateFrame',
				url : 'ApplyCertificateFrame.html',
				pageParam : {
					quarter_name : data.qname,
					id : data.id, //认证id
					certificate_money : data.certificate_money, //纸质证书费用
					sourceurl : window.location.pathname,
					sourcetitle : document.title
				}
			});
		}

		function openApplyScore(index) {
			ShowToast('已经申请成功纸质证书');
		}
	</script>
</html>